<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>MoviePlatForm-登录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="../managerstatic/favicon.ico" type="image/x-icon" rel="shortcut icon" />

    <link href="../managerstatic/plugins/layui/css/layui.css" rel="stylesheet" />
    <link href="../managerstatic/css/layadmin.css" rel="stylesheet" />
    <link href="../managerstatic/css/laylogin.css" rel="stylesheet" />


    <link href="../managerstatic/css/layloginLuyun.css" rel="stylesheet" />
</head>

<body class="layui-layout-body">
<script src="../managerstatic/plugins/jquery.min.js"></script>
<script src="../managerstatic/plugins/layui/layui.js"></script>
<script src="../managerstatic/js/javascript.util.js"></script>


<div id="LAY_app">
    <div class="layadmin-user-login" id="LAY-user-login" style="display: none;">

        <div class="layadmin-user-login-main">
            <div class="layadmin-user-login-box layadmin-user-login-header">
                <h2>登录</h2>
                <p>MoviePlatForm</p>
            </div>
            <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-username"
                           for="LAY-user-login-username"></label>
                    <input type="text" name="username" id="LAY-user-login-username"
                           lay-verify="username" placeholder="账号" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-password"
                           for="LAY-user-login-password"></label>
                    <input type="password" name="password" id="LAY-user-login-password"
                           lay-verify="password" placeholder="密码" class="layui-input">
                    <label id="showPasswordIcon">
                        <i class="layui-icon layui-icon-menu-fill"></i>
                    </label>
                </div>
                <div style="margin-top: 20px;margin-bottom: 20px">
                    <img id="checkCode"  src="/cinemaAdmin/checkCode" onclick="changeCaptcha();" align="middle" style="cursor:pointer;width:65px;margin-left: 10px"/>
                    <input type="text" name="ckeckcode" id="ckeckcode"
                           lay-verify="checkcode" placeholder="请输入验证码" class="layui-input" style="width: 185px;float: left">

                </div>
                <div class="layui-form-item" style="display: none">
                    <input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
                    <div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>记住密码</span>
                        <i class="layui-icon"></i>
                    </div>
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid" id="submitUser" lay-submit=""
                            lay-filter="LAY-user-login-submit">
                        登 入
                    </button>
                </div>
            </div>
        </div>

        <div class="layui-trans layadmin-user-login-footer beijtoum">
            <p style="color: #fff">&copy; 2019 <a style="color: #fff" href="https://gitee.com/cluyun"
                                                  target="_blank">Freedom</a></p>
        </div>
    </div>
</div>
<script>

    (function(){
        if (getIsWeb() === false) {
            alert('建议在web服务容器中打开此网页，如iis、Apache Tomcat、Nginx、node server等。当前状态下被限制了很多功能。');
        }

        pageKeepTop();
    }());

    $(function () {

        //首次进入页面让第一个文本框获得焦点,这样用户直接回车即可登录。
        $('[name="username"]').focus();


        var showPasswordFun = function () {
            $(this).html('<i class="layui-icon layui-icon-circle"></i>');
            $('[name="password"]').attr('type', 'text');
        }
        var hidePasswordFun = function () {
            $(this).html('<i class="layui-icon layui-icon-menu-fill"></i>');
            $('[name="password"]').attr('type', 'password');
        }

        //按住密码框小圆点可显示密码(支持移动端和PC端)
        $('#showPasswordIcon').on("mousedown", showPasswordFun).on('mouseup', hidePasswordFun).on('touchstart', showPasswordFun).on('touchend', hidePasswordFun);

        layui.use(['form', 'layer'], function () {
            var layer = layui.layer;
            var form = layui.form;

            //自定义验证规则
            form.verify({
                username: function (value) {
                    if (value.length < 1) {
                        return '请输入账号';
                    }
                }
                , password: [/(.+){6,12}$/, '密码必须6到12位'],
                checkcode: function (value) {
                    if (value.length < 1) {
                        return '请输入验证码';
                    }
                }
            });

            //提交
            form.on('submit(LAY-user-login-submit)', function (obj) {
                var result = obj.field;
                $("#submitUser").addClass("layui-btn-disabled").prop("disabled", true).text("登录中…");

                $.ajax({
                    url: '/cinemaAdmin/adminLogin',
                    type: 'post',
                    data: {
                        'account': result.username,
                        'password': result.password,
                        'ckeckcode': result.ckeckcode
                    },
                    success: function (data) {
                        if(data.code==200){
                            setTimeout("top.location.replace('index.html')", "1000");
                        }else{
                            changeCaptcha();
                            layer.msg(data.msg, { anim: 10, icon: 0 });
                            $("#submitUser").removeClass("layui-btn-disabled").prop("disabled", false).text("登 入");
                        }
                    }
                })
                return false;
            });

        });


        $(document).on("keyup", "input", function (event) {
            if (event.keyCode == 13) {
                $('#submitUser').click();
            }
        });


    });

    /* 点击切换验证码 */
    function changeCaptcha(){
        $("#checkCode").attr("src","/cinemaAdmin/checkCode?a"+ Math.random());
    }
</script>
</body>

</html>